package cz.muni.fi.heathrow.dao;

import cz.muni.fi.heathrow.entities.Destination;
import cz.muni.fi.heathrow.entities.Flight;
import cz.muni.fi.heathrow.exceptions.ServiceFailureException;
import java.util.Calendar;
import java.util.List;

/**
 * Data Access Object for Flight entity
 * 
 * @author Jan Richter
 */
public interface FlightDAO {
   
    /**
     * Persists Flight
     * @throws ServiceFailureException when operation fails
     * @throws IllegalArgumentException when flight is null or flight id is not null
     * @param flight Flight to be persisted
     */
    void create(Flight flight);
    
    
    /**
     * Retrieves Flight by id
     * @throws ServiceFailureException when operation fails
     * @throws IllegalArgumentException when id is null
     * @param id Id of the flight to be retrieved
     * @return Flight with given id
     */
    Flight get(Long id);
    
    
    /**
     * Updates specified Flight
     * @throws ServiceFailureException when datastore operation fails
     * @throws IllegalArgumentException when flight is null or flight id is null
     * @param flight Flight to be updated accordingly
     */
    void update(Flight flight);
    
    
    /**
     * Removes specified Flight
     * @throws ServiceFailureException when datastore operation fails
     * @throws IllegalArgumentException when flight is null or flight id is null
     * @param flight Flight to be removed
     */
    void remove(Flight flight);
   
    
    /**
     * Retrieves all Flights 
     * @throws ServiceFailureException when datastore operation fails
     * @return List of all Flights present in the database
     */
    List<Flight> findAll();
    
    
    /**
     * Retrieves all Flights with takeoff time in specified time period
     * @throws ServiceFailureException when datastore operation fails
     * @throws IllegalArgumentException when date from or till is null
     * @param from Beginning of the time period
     * @param till End of the time period
     * @return List of all Flights with takeoff within specified time period
     */
    List<Flight> findByTakeoff(Calendar from, Calendar till) ;
    
    
    /**
     * Retrieves all Flights with specified destination
     * @throws ServiceFailureException when datastore operation fails
     * @throws IllegalArgumentException when destination is null
     * @param destination Destination of the flight
     * @return List of all Flights with specified destination
     */
    List<Flight> findByDestination(Destination destination);
}
